<template>
	<div>
		<u-button @click="test">添加就诊人</u-button>
	</div>
</template>

<script>
	var plugin = requirePlugin("healthCardPlugins")
	import healthCardApi from './healthCard';
	export default {
		data() {
			return {
				wechatcode: true
			}
		},
		onShow() {
			
		},
		methods: {
			authSuccess(e) {
			    console.log('🐞 authSuccess', e);
			},
			authFail(e) {
			    console.log('🐞 authFail', e);
			},
			authCancel(e) {
			    console.log('🐞 authCancel', e);
			},
			test() {
				plugin.login((isok, res) => {
				  // 调试日志，联调有问题时提供
				  console.log('🐞 pligin.login', isok, JSON.stringify(res))
					console.log(res.result.wechatCode)
					healthCardApi.api_registerHealthCardPreAuth(res.result.wechatCode).then((res) => {
						console.log(res)
						let result = JSON.parse(res.data)
						let bindCardUrl = result.bindCardUrl
						uni.navigateTo({
							url: '/pagesB/healthCard/webviewPage?url=' + encodeURIComponent(bindCardUrl)
						})
					})
				  if (!isok && res.result.toLogin) {
				    // 用户未授权，需要用户同意授权
				    // 显示 healthCardLogin 登录组件，引导用户同意授权
				    // ...
				  } else {
				    // 用户在微信授权过，可直接获取登录信息
				    // ...
				  }
				}, {
				  wechatcode: true
				})
			}
		}
	}
</script>

<style>
</style>